package view
{
	import map.data.Obstacle;
	
	import flash.display.Sprite;
	import flash.filters.GlowFilter;
	
	public class ObstacleView extends Sprite
	{
		private var _obstacle:Obstacle;
		private var _selected:Boolean;
		public function ObstacleView(obs:Obstacle)
		{
			super();
			_obstacle = obs;
			this.graphics.beginFill(0xffffff);
			this.graphics.lineStyle(2,0xffffff);
			this.graphics.drawCircle(_obstacle.line.p1.x,_obstacle.line.p1.y,5);
			this.graphics.drawCircle(_obstacle.line.p2.x,_obstacle.line.p2.y,5);
			this.graphics.moveTo(_obstacle.line.p1.x,_obstacle.line.p1.y);
			this.graphics.lineTo(_obstacle.line.p2.x,_obstacle.line.p2.y);
			this.graphics.endFill();
		}
		
		public function get obstacle():Obstacle
		{
			return _obstacle;
		}

		public function get selected():Boolean
		{
			return _selected;
		}

		public function set selected(value:Boolean):void
		{
			if(_selected == value) return;
			_selected = value;
			if(_selected)
			{
				filters = [new GlowFilter(0x0000ff,0.8,10,10,10)];
			}else{
				filters = [];
			}
		}
		
		
	}
}